<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title> 文章分类列表</title>
    <link rel="stylesheet" href="${base}/res/manage/css/common.css">
    <link rel="stylesheet" href="${base}/res/manage/css/ec.css">
    <link rel="stylesheet" href="${base}/res/manage/css/list.css">
    <script type="text/javascript" src="${base}/res/plugin/jquery/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="${base}/res/plugin/validator/jquery.validate.min.js"></script>
    <script type="text/javascript" src="${base}/res/admin/js/common.js"></script>
    <script type="text/javascript" src="${base}/res/admin/js/list.js"></script>
    <script type="text/javascript" src="${base}/res/admin/js/initWidth.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
        [@flash_message /]

            //删除
            $("a[class=delete]").click(function () {

                var articleTypeId = $(this).attr("idVal");
                if (articleTypeId == null || articleTypeId == "") {
                    alert("必需参数错误!");
                    return;
                }
                ;

                //验证是否含有子节点
                $.post("isRootNode.jhtml", {id: articleTypeId}, function (data) {

                    if (data) {
                        alert("此节点下含有子节点，不能隔级删除");
                        return false;
                    } else {
                        if (confirm("确定要删除此信息吗?")) {
                            location.href = "delete.jhtml?id=" + articleTypeId;
                        }
                    }

                });
            });
            $(".disabled,.launch").on("click", function () {
                var text = "";
                if ($(this).hasClass("launch")) {
                    text = "是否启用?";
                } else {
                    text = "是否禁用?";
                }
                if (confirm(text)) {
                    var id = $(this).attr("data-id");
                    var status = $(this).attr("data-isenabled")
                    location.href = "disabled.jhtml?id=" + id+"&isEnabled="+status;
                }
            })
        });
    </script>
</head>
<body>
<div class="tab set">
    <h3>[#--<a href="javascript:;">首页</a>--]<a href="javascript:;">微信管理</a><a href="list.jhtml">> 文章分类管理</a></h3>
    <form id="listForm" action="list.jhtml" method="get">
        <div class="txte">
            <p class="txtl" ><a href="${base}/admin/wxArticleType/add.jhtml" class="ared "> + 添加文章分类</a></p>
        </div>
        <div class="tablist">
            <table cellpadding="0" cellspacing="0" class="scrollTable" >
                <tr>
                    <th width="20%">栏目名称</th>
                    <th width="15%">等级</th>
                    <th width="15%">是否可用</th>
                    <th width="15%">是否默认</th>
                    <th width="15%">创建时间</th>
                    <th width="20%" class="icon">操作</th>
                </tr>
            [#list articleTypes as articleType]
                <tr>
                    <td>
                        <span style="margin-left: ${articleType.grade * 20}px;">
                        ${articleType.name}
                        </span>
                    </td>
                    <td>
                    ${articleType.grade}
                    </td>
                    <td>
                    ${articleType.isEnabled?string("可用","不可用")}
                    </td>
                    <td>
                    ${articleType.isDefault?string("默认","非默认")}
                    </td>
                    <td>
                        <span title="${articleType.createDate?string("yyyy-MM-dd")}">${articleType.createDate?string("yyyy-MM-dd")}</span>
                    </td>
                    <td class="icon">
                        <div>
                            <a class="[#if articleType.isEnabled]disabled[#else ]launch[/#if]" title="[#if articleType.isEnabled]禁用[#else ]启用[/#if]" data-id="${articleType.id}" data-isenabled="${articleType.isEnabled?string(1,0)}" ></a>
                            <a class="delete" title="删除" idVal="${articleType.id}"></a>
                            <a class="edit" title="编辑" href="edit.jhtml?id=${articleType.id}"></a>
                        </div>
                    </td>
                </tr>
            [/#list]
            </table>
        [@pagination pageNumber = page.pageNumber totalPages = page.pages]
            [#include "/admin/include/pagination.ftl"]
        [/@pagination]
        </div>
    </form>
</div>
</body>
</html>